home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Snippets
/
PPP_PrefSaver 1.1
/
C Source
/
PPP-Prefs.h
< prev
Wrap
C/C++ Source or Header
|
1996-05-18
|
4KB
|
139 lines
#pragma once
#include <Folders.h>
#include <Files.h>
/****** COMPILER DIRECTIVES ********/
#define STANDALONE 1 /* False - compiling as an 'IEnd' code resource
(Set only the Purgeable flag, ID 128, or if using
InstallerMaker 3.0, set the ID to 256)
True - compiling as standalone application
(Set only the 32bit compatible flag, 100K partition,
Creator Type 'RSED', File Type 'rsrc') */
#define USE_SCRIPT 1 /* True - Save settings into the connect script of
the active server, False - save settings into
the Authentication settings of the active server */
#define DEMO_ONLY 0 /* True if you want to compile code that just demonstrates
the code without actually saving anything into the prefs */
// Connect script fields to use, if writing into the connect script...
#define NAME_COMMAND 1 // Which script command (0-7) to save Name in?
#define PWORD_COMMAND 3 // Which script command to save password in?
// Alert tells user we can't enter PPP pref settings due to an error
#define rErrorAlert 5000
// Type definitions
typedef unsigned char uchar;
#if STANDALONE
void main( void );
#else
pascal short main(short abort,short vol,long dir,uchar *name,
unsigned short packages);
#endif
void HandleError(OSErr errNum);
short OpenPPP_Prefs(OSErr *err);
OSErr GetPPP_Pref(struct ppp_pref *thePref);
OSErr GetPPP_Config(struct ppp_config *theConfig,short confignum);
void PutPPP_Config(struct ppp_config theConfig,short confignum);
typedef unsigned char b_8; /* 8-bit quantity */
typedef unsigned short b_16; /* 16-bit quantity */
typedef unsigned long b_32; /* 32-bit quantity */
#define MAXSLEN 42 /* max string length */
#define NUMCOMMANDS 8 /* number of strings */
#define PREF_VERSION 3 /* version of prefs file */
#define NUMCONFIGS 4 /* number of configurations */
struct lcp_value_s {
b_16 mru; /* Maximum Receive Unit */
b_16 authentication; /* Authentication protocol */
b_32 accm; /* Async Control Char Map */
b_32 magic_number; /* Magic number value */
};
struct ipcp_value_s {
b_32 address; /* address for this side */
b_32 other; /* address for other side */
b_16 compression; /* Compression protocol */
b_16 slots; /* Slots (0-n)*/
b_8 slot_compress; /* Slots may be compressed (flag)*/
};
union value_s {
struct lcp_value_s lcp_option;
struct ipcp_value_s ipcp_option;
};
struct lcp_will_want {
b_16 will_negotiate, want_negotiate;
struct lcp_value_s want;
};
struct lcpconfig {
struct lcp_will_want local, remote;
b_8 req_tries;
b_8 timeout;
};
struct ppp_pref {
b_16 version; /* version of Preferences file (should be 3) */
b_8 portname[32]; /* port name (from CommToolBox) */
Boolean hangup; /* send modem hangup command on close */
Boolean use_pulse; /* use pulse for dialing */
Boolean quiet; /* Quiet mode flag */
Boolean use_term; /* bring up a terminal window on connection establishment */
b_16 timeout; /* idle timeout (minutes), 0 = none */
b_16 echo; /* PPP LCP echo interval 0 = off */
b_16 active_config; /* active config index */
b_16 max_config; /* maximum conifg index */
b_16 echo_tries; /* number of echos before down */
b_16 max_window; /* maximum window size */
};
/* And this is the structure of ppp_config : */
struct ipcp_will_want {
b_16 will_negotiate, want_negotiate;
struct ipcp_value_s want;
};
struct ipcpconfig {
struct ipcp_will_want local, remote;
b_8 req_tries;
b_8 timeout;
};
struct connectScript{
Boolean sendout; /* should we send or wait for this string */
Boolean addreturn; /* add a carriage return to end of string */
b_8 scriptstr[MAXSLEN + 1]; /* script string */
};
struct ppp_config {
struct lcpconfig lcpconf;
struct ipcpconfig ipcpconf;
b_8 pap_retries; /* number of tries for PAP */
b_8 pap_timeout; /* timeout for PAP */
b_16 connecttimeout;
b_16 waittimeout;
b_16 baudrate; /* port speed */
b_8 flags;
#define CTSBIT 0x1
#define RTSBIT 0x2
#define FLOWBITS CTSBIT+RTSBIT
#define USE_PULSE 0x4
b_8 config_name[MAXSLEN + 1]; /* configuration name */
b_8 defaultid[MAXSLEN + 1]; /* add one for length byte */
b_8 defaultpw[MAXSLEN + 1];
b_8 modeminit[MAXSLEN + 1];
b_8 phonenum[MAXSLEN + 1];
struct connectScript commands[NUMCOMMANDS];
};